<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Toutiao;

class ToutiaoRecordController extends Controller
{

        public function index(Request $request){
            $where = function ($query) use ($request) {
                if ($request->has('mobile') and $request->mobile != '') {
                    $query->where('mobile', $request->mobile);
                }

                if($request->has('status') and $request->status !== '') {
                    if($request->status != -1) {
                        $query->where('status', $request->status);
                    }
                }

                if($request->has('name') and $request->name != '') {
                    $query->where('name',$request->name);
                }
            };

            $records = Toutiao::where($where)->orderBy('time','desc')
                ->paginate(10);
            //return $records;
            return view('admin.toutiao.index',compact('records'));
        }
}


